Public Class CSSE
   Protected _Score As Integer
   Protected _Unit As Integer
   Protected _ScoreRangeMin As Integer
   Protected _ScoreRangeMax As Integer
   Protected _UnitRangeMin As Integer
   Protected _UnitRangeMax As Integer

   Sub New()
      _UnitRangeMin = 1
      _UnitRangeMax = 10
   End Sub

   Public Overridable Property Score()
      Get
         Return _Score
      End Get
      Set(ByVal value)
         _Score = value
      End Set
   End Property

   Public Overridable Property Unit()
      Get
         Return _Unit
      End Get
      Set(ByVal value)
         If value >= _UnitRangeMin And value <= _UnitRangeMax Then
            _Unit = value
         Else
            Err.Raise(33401, "Unit", "KarbassA::Unit would be out of range!")
         End If
      End Set
   End Property

   Public Sub Inc()

      If Unit < _UnitRangeMin Or Unit > _UnitRangeMax Then
         Err.Raise(33401, "Unit", "KarbassA::Unit would be out of range!")
      ElseIf (Score + Unit) < _ScoreRangeMin Or (Score + Unit) > _ScoreRangeMax Then
         Err.Raise(33402, "Score", "KarbassA::Value would be out of range!")
      Else
         _Score += _Unit
      End If

      If _Score = _ScoreRangeMax Then
         PerfectScoreReached()
      End If

   End Sub

   Public Event PerfectScore()

   Protected Sub PerfectScoreReached()
      RaiseEvent PerfectScore()
   End Sub

End Class
